package com.xbts.system.domain;

import java.math.BigDecimal;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.Data;
import com.xbts.common.annotation.Excel;
import com.xbts.common.utils.StringUtils;
import com.xbts.common.core.domain.BaseEntity;

/**
 * 云市场规格对象 cn_cloud_market_sku
 *
 * @author xbts
 * @date 2023-08-22
 */
@Data
@ApiModel("云市场规格对象")
@TableName("cn_cloud_market_sku")
public class CnCloudMarketSku extends BaseEntity {

private static final long serialVersionUID=1L;

    /** 主键 */
    @TableId
    @JsonSerialize(using= ToStringSerializer.class)
    private String marketSkuId;

    /** 云市场表主键 */
    @Excel(name = "云市场表主键")
    @ApiModelProperty("云市场表主键")
    @NotNull(message = "云市场表主键不能为空")
    @JsonSerialize(using= ToStringSerializer.class)
    private Long marketId;

    /** 一级规格名称 */
    @Excel(name = "一级规格名称")
    @ApiModelProperty("一级规格名称")
    @NotEmpty(message = "一级规格名称不能为空")
    private String firstSkuName;

    /** 二级规格名称 */
    @Excel(name = "二级规格名称")
    @ApiModelProperty("二级规格名称")
    private String secondSkuName;

    /** 云市场购买方式 */
    @Excel(name = "云市场购买方式：0按次 1按天 30按月 365按年")
    @ApiModelProperty("云市场购买方式")
    @NotEmpty(message = "云市场购买方式不能为空")
    private String cloudMarketBuyingMethod;

    /** 价格 */
    @Excel(name = "价格")
    @ApiModelProperty("价格")
    private BigDecimal price;

    /** 删除标志（0代表存在 1代表删除） */
    private Boolean deleteFlag;

    public<T> QueryWrapper<T> queryWrapper(){
        QueryWrapper<T> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq(StringUtils.isNotNull(marketId),"market_id", marketId);
        queryWrapper.like(StringUtils.isNotEmpty(firstSkuName),"first_sku_name", firstSkuName);
        queryWrapper.like(StringUtils.isNotEmpty(secondSkuName),"second_sku_name", secondSkuName);
        queryWrapper.like(StringUtils.isNotEmpty(cloudMarketBuyingMethod),"cloud_market_buying_method", cloudMarketBuyingMethod);
        queryWrapper.orderByDesc("create_time");
        return queryWrapper;
    }
}